/*******************************************************************************
 * @file fdt_config.h
 * @brief  inter process Fast Data Transfer
 *
 *
 * Author: Kevinx
 *
 * Copyright (c) 2015 Kevinx. All Rights Reserved.
 *
 * CONFIDENTIALITY AND LIMITED USE
 *
 * This software, including any software of third parties embodied herein,
 * contains information and concepts which are confidential to Kevinx
 * and such third parties. This software is licensed for use
 * solely in accordance with the terms and conditions of the applicable
 * license agreement with Kevinx or its authorized distributor.
 ************************************************************************************/
#ifndef __FDT_CONFIG_H__
#define __FDT_CONFIG_H__
#include <stdint.h>

extern struct fdt_shmmgr shmmgr;

#define shmmgr_ptr (&shmmgr)

#define MAX_L2CELL_NR 3
#define MEGABYTES(m) (m << 20)

#define RCV_BUF_SZ 1800

#define MKCID(cid, pid, mbytes) {cid, pid, MEGABYTES(mbytes)}

#define SECONDARY_ID(i) "MAC"#i
#define MK_SEC_CID(i, mbytes) MKCID("FDTCH"#i, SECONDARY_ID(i), mbytes)
#define SEC_SHMA_SZ 16

#define mk_secondary_cids() \
{ \
    MK_SEC_CID(0, SEC_SHMA_SZ), \
    MK_SEC_CID(1, SEC_SHMA_SZ), \
    MK_SEC_CID(2, SEC_SHMA_SZ)  \
}

#define GEN_MACID(i) ({ \
    const char* __macid = NULL; \
    switch (i) { \
        case 0: \
        __macid = "MAC0"; \
        break; \
        case 1: \
        __macid = "MAC1"; \
        break; \
        case 2: \
        __macid = "MAC2"; \
        break; \
    } \
    __macid; })

#define PRIMARY_ID "PDCP"
#define MK_PRIM_CID(i, mbytes) MKCID("FDTCH"#i, PRIMARY_ID, mbytes)
#define PRIM_SHMA_SZ (16) 

#define mk_primary_cids() \
{ \
    MK_PRIM_CID(0, PRIM_SHMA_SZ), \
    MK_PRIM_CID(1, PRIM_SHMA_SZ), \
    MK_PRIM_CID(2, PRIM_SHMA_SZ) \
}

#define PDCP_ID PRIMARY_ID

#define fdtch_array_initialzer() {NULL, NULL, NULL}

/* PDCP<->RLC Data Link Port */
#define L2_PORT_BASE    54380
#define PDCP_DLINK_PORT 40001

#define INGRESS_SHMA_SZ (32)
#define EGRESS_SHMA_SZ  (16)

#ifdef USE_FDTCH
#    define PDCP_SHMA_SZ  MEGABYTES(PRIM_SHMA_SZ)
#    define RLC_SHMA_SZ   MEGABYTES(SEC_SHMA_SZ)
#else 
#    define PDCP_SHMA_SZ  MEGABYTES(32)
#    define RLC_SHMA_SZ   MEGABYTES(16)
#endif /* USE_FDTCH */

#endif /* __FDT_CONFIG_H__ */

